import { S } from '../../s';
import { IPSAppDELogicNode } from '../../app/dataentity/ipsapp-delogic-node';
import { IPSDELogicLink } from './ipsdelogic-link';
import { IPSDELogicNode } from './ipsdelogic-node';
import { IPSDELogicNodeParam } from './ipsdelogic-node-param';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicNodeImpl
  extends PSModelObjectImpl
  implements IPSDELogicNode, IPSAppDELogicNode
{
  get codeName(): string {
    return this.M.codeName;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0;
  }

  get leftPos(): number {
    return this.M.leftPos != null ? this.M.leftPos : 0;
  }

  get logicNodeType():
    | 'BEGIN'
    | 'DEACTION'
    | 'PREPAREPARAM'
    | 'RESETPARAM'
    | 'COPYPARAM'
    | 'BINDPARAM'
    | 'APPENDPARAM'
    | 'SORTPARAM'
    | 'RENEWPARAM'
    | 'FILTERPARAM'
    | 'FILTERPARAM2'
    | 'MERGEPARAM'
    | 'AGGREGATEPARAM'
    | 'LOOPSUBCALL'
    | 'RAWSQLCALL'
    | 'RAWSQLANDLOOPCALL'
    | 'RAWWEBCALL'
    | 'STARTWF'
    | 'CANCELWF'
    | 'THROWEXCEPTION'
    | 'SFPLUGIN'
    | 'RAWSFCODE'
    | 'SYSLOGIC'
    | 'SYSUTIL'
    | 'PREPAREJSPARAM'
    | 'VIEWCTRLINVOKE'
    | 'RAWJSCODE'
    | 'MSGBOX'
    | 'PFPLUGIN'
    | 'DEUIACTION'
    | 'MAINSTATE'
    | 'DEDATASET'
    | 'DENOTIFY'
    | 'DELOGIC'
    | 'COMMIT'
    | 'ROLLBACK'
    | 'DEBUGPARAM'
    | 'DEDATAQUERY'
    | 'DEPRINT'
    | 'DEREPORT'
    | 'DEDTSQUEUE'
    | 'DEDATASYNC'
    | 'DEDATAIMP'
    | 'DEDATAEXP'
    | 'DEDATAAUDIT'
    | 'SUBSYSSAMETHOD'
    | 'SYSDATASYNCAGENTOUT'
    | 'SYSDBTABLEACTION'
    | 'SYSBDTABLEACTION'
    | 'SYSSEARCHDOCACTION'
    | 'SYSBIREPORT'
    | 'END' {
    return this.M.logicNodeType;
  }

  protected psdelogiclinks: IPSDELogicLink[];
  getPSDELogicLinks(): IPSDELogicLink[] | null {
    return (
      this.psdelogiclinks ||
      (this.psdelogiclinks = this.fillChildListModel(
        this.M.getPSDELogicLinks,
        S._1da,
      ) as IPSDELogicLink[])
    );
  }

  findPSDELogicLink(objKey: any): IPSDELogicLink | null {
    return this.getPSModel5(
      S._1da,
      this.getPSDELogicLinks(),
      objKey,
    ) as IPSDELogicLink;
  }

  protected psdelogicnodeparams: IPSDELogicNodeParam[];
  getPSDELogicNodeParams(): IPSDELogicNodeParam[] | null {
    return (
      this.psdelogicnodeparams ||
      (this.psdelogicnodeparams = this.fillChildListModel(
        this.M.getPSDELogicNodeParams,
        S._1df,
      ) as IPSDELogicNodeParam[])
    );
  }

  findPSDELogicNodeParam(objKey: any): IPSDELogicNodeParam | null {
    return this.getPSModel5(
      S._1df,
      this.getPSDELogicNodeParams(),
      objKey,
    ) as IPSDELogicNodeParam;
  }

  get topPos(): number {
    return this.M.topPos != null ? this.M.topPos : 0;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0;
  }

  get parallelOutput(): boolean {
    return this.M.parallelOutput != null ? this.M.parallelOutput : false;
  }
  get cls(): string {
    return 'PSDELogicNodeImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._1dc || cls == S._1dd) return true;
    return super.instanceof(cls);
  }
}
